package com.hxexp.weixin.test;

import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

import org.junit.Assert;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;

import com.hxexp.weixin.common.security.SignatureHelper;
import com.hxexp.weixin.test.runner.JUnit4WithLogClassRunner;

@RunWith(JUnit4WithLogClassRunner.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class SignatureHelperTester {

    @Test
    public void testCase01() {
        String[] str = { "3", "5", "2", "1", "4" };
        String[] expected = { "1", "2", "3", "4", "5" };
        String[] returnValue = SignatureHelper.bubbleSort(str);
        Assert.assertArrayEquals(expected, returnValue);
    }

    @Test
    public void testCase02() {
        Map<String, String> map = new HashMap<String, String>();
        Map<String, String> expected = new TreeMap<String, String>();
        map.put("2", "ee");
        map.put("1", "rr");
        map.put("3", "qq");
        expected.put("1", "rr");
        expected.put("2", "ee");
        expected.put("3", "qq");
        Map<String, String> returnValue = SignatureHelper.sortMapByKey(map);
        Assert.assertEquals(expected, returnValue);
    }
}
